<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box{
        width: 700px;
        height: 500px;
        background-color: hotpink;
        margin:0 auto;
        overflow: auto;
        border: 1px,solid,pink;
    }
    .log{
        margin-left: 30px;
    }
</style>
<body>
    <div class="box">
        <div><h1><strong>log:</strong></h1></div>
        <div class="log"></div>
    </div>
</body>
<script>
    const logDiv = document.querySelector('.log')
    const boxDiv = document.querySelector('.box')
    // 获取logDiv的innerHTML
    console.log(logDiv.innerHTML);

    function log(msg){
        const logDiv = document.querySelector('.log')
        // logDiv.innerHTML会获取当前目标元素里面的内容
        logDiv.innerHTML += msg
    }
    // log("nihao")
    // log("nihao123")

    function logEvent(event){
        let msg = "lalalalalla<br>"
        log(msg)
    }

    boxDiv.addEventListener("mouseenter",logEvent)
    boxDiv.addEventListener("mouseleave",logEvent)
    
</script>
</html>